package com.example.myapplication7;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText editText1=findViewById(R.id.user);
        EditText editText2=findViewById(R.id.password);
        SharedPreferences sharedPreferences=getSharedPreferences("personal", Context.MODE_PRIVATE);
        editText1.setText(sharedPreferences.getString("user",""));
        editText2.setText(sharedPreferences.getString("password",""));
    }
    public void out(View view) {
        this.finish();
    }

    public void login(View view) {
        String user=((EditText)findViewById(R.id.user)).getText().toString();
        String password=((EditText)findViewById(R.id.password)).getText().toString();
        SharedPreferences sharedPreferences=getSharedPreferences("personal", Context.MODE_PRIVATE);
        sharedPreferences.edit().putString("user",user).apply();
        sharedPreferences.edit().putString("password",password).apply();
        Intent intent=new Intent(MainActivity.this,MainActivity2.class);
        intent.putExtra("user",user);
        startActivity(intent);
    }
}